package com.menhai.personmanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.menhai.personmanagement.entity.TjInspectphysical;
import com.menhai.personmanagement.entity.co.TjInspectphysicalCo;
import com.menhai.personmanagement.entity.co.TjSkCo;
import com.menhai.personmanagement.entity.vo.TjInspectphysicalVo;
import com.menhai.personmanagement.entity.vo.TjInspectphysicalfrontVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author shikun
 * @since 2022-01-12
 */
@Mapper
public interface TjInspectphysicalMapper extends BaseMapper<TjInspectphysical>{


    int bodycheckupnumber(@Param("superiorCode") String superiorCode);

    @Select("select * from tj_inspectphysical where mbpeopleId=${mbpeopleId} and hosnum=#{mbhosnum} and date_sub(curdate(), INTERVAL ${tian} DAY) <=  STR_TO_DATE(createTime,'%Y-%m-%d')")
    public List<TjInspectphysical> findHistoryByDate(@Param("tian") int tian,@Param("mbpeopleId") int mbpeopleId,@Param("mbhosnum") String mbhosnum);

    @Select("select * from tj_inspectphysical where mbpeopleId = ${mbpeopleId} and hosnum like #{hosnum} AND state = 1")
    public List<TjInspectphysical> findHistoryByPeopleId(@Param("mbpeopleId") int mbpeopleId,@Param("hosnum") String hosnum);

    List<Map<String, Object>> getAllInspectByUserName(@Param("name") String name, @Param("level") String level, @Param("date") String date,@Param("pagesize") int pagesize,@Param("pagenum") int pagenum);

    int sixtycheckupnumber(@Param("superiorCode") String superiorCode);

    int eighteenarrivesixtynumber(@Param("superiorCode") String superiorCode);

    int eighteenundernumber(@Param("superiorCode") String superiorCode);

    int nowadaysnumber(@Param("superiorCode") String superiorCode);

    int thisweeknumber(@Param("superiorCode") String superiorCode);

    int thismonthnumber(@Param("superiorCode") String superiorCode);

    List<TjInspectphysicalfrontVo> bodydetectagelayered(String superiorCode);

    List<TjInspectphysicalfrontVo> bodydetesex(String superiorCode);

    List<TjInspectphysicalfrontVo> dailybodycheck(@Param("superiorCode") String superiorCode);

    List<Map<String,Object>> getAllInspect(String hosnum,int pagesize,int pagenum,String date);

    int getPageTotal(String hosnum,String date,String name);

    IPage<TjInspectphysicalVo> selectBycreateTime(@Param("page") Page<TjInspectphysicalVo> page, @Param("tjSkCo") TjSkCo tjSkCo);

    List<TjInspectphysicalVo> exportBycreateTime(@Param("tjSkCo") TjSkCo tjSkCo);

    IPage<TjInspectphysicalVo> selectBymonthgrouping(@Param("page") Page<TjInspectphysicalVo> page, @Param("tjSkCo") TjSkCo tjSkCo);

    List<TjInspectphysicalVo> exportBymonthgrouping(@Param("tjSkCo") TjSkCo tjSkCo);

    List<TjInspectphysicalVo> finishbodycheckuplist(@Param("tjInspectphysical") TjInspectphysicalCo tjInspectphysical);

    int batchInsert(List val);

    @Select("select * from tj_inspectphysical where mbpeopleId=${peopleId} and reportId IS NOT NULL")
    List<TjInspectphysical> getReports(@Param("peopleId") String peopleId);

    /**
     * 查询中医体检记录列表
     * @param page
     * @param
     * @return
     */
    IPage<TjInspectphysicalCo> getInspectPhysicalList(@Param("page")Page<TjInspectphysicalCo> page, @Param("tjInspectphysicalCo") TjInspectphysicalCo tjInspectphysicalCo);

    /**
     * 左侧树
     * @param hosnum
     * @return
     */
    public List<Map<String,Object>> getCunRenShu(@Param("hosnum")String hosnum);
}
